import Book.BookList;
import User.AdmainUser;
import User.NormalUser;
import User.User;
import java.util.Scanner;

public class Main {



    public static User login(){
        System.out.println("请输入你的名字");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        System.out.println("管理员》1   读者》0");
        int num = scanner.nextInt();
       if(num==1){
           System.out.println("请输入密码");
           String str = scanner.next();
           if(AdmainUser.check(str)){
               return new AdmainUser(name);
           }else{
               return null;
           }
        }else if(num==0){
           return new NormalUser(name);
        } else {
           System.out.println("啥也不是");
           return null;
       }
    }

    public static void main(String[] args) {

        BookList booklist = new BookList();
        Scanner scanner = new Scanner(System.in);
        User text = login();
        User user = null;
        if(text!=null){
             user = text;
            text = null;
        }
        else{
            text = null;
            System.out.println("身份输入错误，程序结束！");
            System.exit(0);
        }

        while(true) {
            int choice = user.menu();
            user.doOperation(choice,booklist);
        }
    }
}
